package com.lsongh.springboot2.controller;

import com.lsongh.springboot2.entity.Culture;
import com.lsongh.springboot2.entity.Result;
import com.lsongh.springboot2.service.CultrueService;
import com.lsongh.springboot2.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CultrueController {

    @Autowired
    CultrueService cultrueService;

    /**
     * 获取分分钟文化人推荐列表
     * @param name
     * @return
     */
    @GetMapping("cultrue/findAll")
    public Result<Culture> findAllCultrue(@RequestParam("name") String name){
        if(name == ""){
            return ResultUtil.success(cultrueService.findAllCultrue(0));
        }else {
            return ResultUtil.success(cultrueService.findAllCultrueByName(0,name));
        }
    }

    @PostMapping("cultrue/update")
    public Result<String> updateCultrue(@RequestBody Culture culture){
        cultrueService.save(culture);
        return ResultUtil.success("修改成功");
    }
}
